package test.dataprovider;

import java.sql.Connection;
import java.sql.SQLException;

import org.junit.Assert;
import org.junit.Test;

import test.util.Constants;

public class ConnectionFactoryTester {

    @Test
    public void test() {
        Connection conn = null;
        try {
            conn = ConnectionFactory.getConnection();
            Assert.assertTrue(conn.isValid(Constants.ONE));
        } catch (SQLException e) {
            e.printStackTrace();
            Assert.fail(e.getMessage());
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            Assert.fail(e.getMessage());
        } finally {
            if (null != conn)
                try {
                    conn.close();
                    Assert.assertTrue(conn.isClosed());
                    conn = null;
                } catch (SQLException e) {
                    e.printStackTrace();
                    Assert.fail(e.getMessage());
                }
            else
                Assert.fail();
        }
    }

}
